package Java学习;

import java.util.Objects;

public class Student implements Comparable<Student>{
    private String name;
    private int age;
    private int chinese;
    private int math;
    private int english;
    private int num;

    public Student() {

    }

    public Student(String name, int age, int chinese, int math, int english, int num) {
        this.name = name;
        this.age = age;
        this.chinese = chinese;
        this.math = math;
        this.english = english;
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", chinese=" + chinese +
                ", math=" + math +
                ", english=" + english +
                ", num=" + num +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && chinese == student.chinese && math == student.math && english == student.english && num == student.num && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, chinese, math, english, num);
    }

    @Override
    public int compareTo(Student o) {
        int i;
        if (this.num==o.num){
            if (this.chinese == o.chinese){
                if (this.math == o.math){
                    if (this.english == o.english){
                        if (this.age == o.age){
                            i = this.name.compareTo(o.name);
                        }
                        else {
                            i = this.age - o.age;
                        }
                    }
                    else {
                        i = this.english - o.english;
                    }
                }
                else {
                    i = this.math - o.math;
                }
            }
            else {
              i = this.chinese - o.chinese;
            }

        }
        else {
             i = this.num - o.num;
        }
        return i;
    }
}
